<template>
    <el-button @click="copyStocksToClipboard"> 复制 </el-button>
</template>

<script setup>
import { ElMessage } from 'element-plus'


const props = defineProps({
        data : Array,
        stocks : [],
    })
const copyStocksToClipboard = () => { 
    let stocks = []
    if (props.data) {
        stocks = props.data.map(item => {
            return item.stock
        })  
    } else if (props.stocks) {
        stocks = props.stocks
    }

    navigator.clipboard.writeText(stocks.join(';'));

        ElMessage({
        message: '复制成功',
        type: 'success',
    })
}
</script>